<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>基金档案信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style type="text/css">
        body {
            background-color: #ffffff;
        }
        /* 设置下拉框宽度 */
        /* input.layui-input.layui-unselect {width:400px} */
    </style>

</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label">基金全称：</label>
        <div class="layui-input-block" style="width: 400px;">
            <input type="hidden" name="id">
            <input  type="text" name="fullName" readonly value="" class="layui-input" >
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">资产规模(亿)：</label>
        <div class="layui-input-block" style="width: 400px;">
            <input type="text" name="asset" readonly value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">基金管理人：</label>
        <div class="layui-input-block" style="width: 400px;">
            <input type="text" name="fundManager" readonly  value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">基金托管人：</label>
        <div class="layui-input-block" style="width: 400px;">
            <input name="fundTrustee" type="text" readonly class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">产品经理：</label>
        <div class="layui-input-block" style="width: 400px;">
            <input type="hidden" name="productManager.id">
            <input  type="text" name="productManager.name" readonly value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">投资理念：</label>
        <div class="layui-input-block" style="width: 500px;">
            <textarea name="investmentPhilosophy" readonly class="layui-textarea" ></textarea>
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">投资策略：</label>
        <div class="layui-input-block" style="width: 500px;">
            <textarea  name="investmentStrategy" readonly class="layui-textarea" ></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">成立日期：</label>
        <div class="layui-input-block" style="width: 400px;">
            <input  type="text" name="establishmentDate" id='test1' readonly value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item" id="createTime">
        <label class="layui-form-label">录入时间：</label>
        <div class="layui-input-block">
            <input style="width: 400px;" type="text" name="createTime" readonly value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item" id="updateTime">
        <label class="layui-form-label">修改时间：</label>
        <div class="layui-input-block">
            <input style="width: 400px;" type="text" name="updateTime" readonly value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block" id="button">
            <!-- <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认修改</button> -->
            <button class="layui-btn" id="update">点击修改</button>
        </div>
    </div>

</div>
<script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../../js/common/constant.js"></script>
<script>
    layui.use(['form','laydate','layer'], function () {
        var laydate = layui.laydate;
        var form = layui.form,
            layer = layui.layer,
            $ = layui.jquery;


        //日期选择
        //常规用法
        laydate.render({
            elem: '#test1',
            type: 'datetime'
        });

        $("#update").click(function(){
            $("#createTime").remove();
            $("#updateTime").remove();
            $(":input").removeAttr("readonly");
            $(':input')[0].style.border="1px solid green";
            $("#button").html('<button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认修改</button>');
        })

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.ajax({
                url:getRootPath()+"web/fundarchive/edit",
                type:'PUT',
                data: data.field,
                dataType:'json',
                success:function(result){
                    var index = layer.alert(result.message, {
                        title: '最终的提交信息',
                    },function () {
                        // 关闭弹出层
                        layer.close(index);
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(iframeIndex);
                        if(result.code==200){
                            window.parent.location.reload();
                        }
                    })
                }
            })

            return false;
        });

        /* 查询当前的基金档案信息 */
        $(function(){
            var url = location.search;
            var i = url.indexOf("=");
            var id = url.substring(i+1);
            $.ajax({
                url:getRootPath()+'web/fundarchive/one',
                type:"GET",
                data:{
                    fundArchiveId:id
                },
                async:false,
                dataType:"json",
                success:function(data){
                    if(data.code == 200){
                        var fundarchive = data.data;
                        $("input[name=id]").val(fundarchive.id)
                        $("input[name='fullName']").val(fundarchive.fullName)
                        $("input[name='asset']").val(fundarchive.asset)
                        $("input[name='fundManager']").val(fundarchive.fundManager)                       
                        $("input[name='fundTrustee']").val(fundarchive.fundTrustee)       
                        $("input[name='productManager.id']").val(fundarchive.productManager.id)            
                        $("input[name='productManager.name']").val(fundarchive.productManager.name)
                        $("input[name='establishmentDate']").val(fundarchive.establishmentDate)
                        $("textarea[name='investmentPhilosophy']").val(fundarchive.investmentPhilosophy)
                        $("textarea[name='investmentStrategy']").val(fundarchive.investmentStrategy)
                        $("input[name='createTime']").val(fundarchive.createTime)
                        $("input[name='updateTime']").val(fundarchive.updateTime)
                    }else{
                        layer.alert(data.message)
                    }
                   
                }
            })
        })
    });

</script>
</body>
</html>